#include <iostream>
using namespace std;

int month_28[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int month_29[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int year;
typedef struct
{
    int month;
    int day;
} Date;

inline bool isLeap(int year)
{
    return (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
}

Date start(int year, Date date, bool flag)
{
    date.month = 1;
    while (true)
    {
        
        if (date.day > (flag ? month_29[date.month - 1] : month_28[date.month - 1]))
        {
            date.day -= (flag ? (month_29[date.month - 1]) : (month_28[date.month - 1]));
            date.month += 1;
        }
        else
        {
            break;
        }
    }
    return date;
}

int main()
{
    Date date;
    while (cin >> year >> date.day)
    {
        date = start(year, date, isLeap(year));
        printf("%d-%02d-%02d\n", year, date.month, date.day);
    }
    return 0;
}